# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
from websocket import create_connection

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    #print_hi('PyCharm')
    ip="127.0.0.1"
    socketport="8765"
    station_id="abc123"
    web_socket = create_connection(f"ws://{ip}:{socketport}/uav/hangarServer/{station_id}", timeout=3000)  # 如果30秒没有收到消息则结束等待
    while web_socket!=None:
        recv_text = web_socket.recv()
        print(f"receive server content {recv_text}")
        content=f"I have received the content {recv_text}"
        web_socket.send(content)


# See PyCharm help at https://www.jetbrains.com/help/pycharm/
